/**************************************************************************
 *         Copyright(c) 2007 by Sunplus mMedia  Technology Co., Ltd.       *
 *                                                                         *
 *  This software is copyrighted by and is the property of Sunplus mMedia  *
 *  Technology Co., Ltd. All rights are reserved by Sunplus mMedia Techno- *
 *  logy Co., Ltd. This software may only be used in accordance with the   *
 *  corresponding license agreement. Any unauthorized use, duplication,    *
 *  distribution, or disclosure of this software is expressly forbidden.   *
 *                                                                         *
 *  This Copyright notice "M U S T" not be removed or modified without     *
 *  prior written consent of Sunplus mMedia Technology  Co., Ltd.          *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd. reserves the right to modify this  *
 *  software without notice.                                               *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd.                                    *
 *  19-1, Innovation First Road, Science-Based Industrial Park,            *
 *  Hsin-Chu, Taiwan, R.O.C.                                               *
 *                                                                         *
 **************************************************************************/
#include "general.h"
#include "app_main.h"
#include "os_msg.h"
#include "initio.h"
#include "app_osd_icon.h"
#include "app_ui_osd.h"
#include "App_ui_para.h"
#include "app_ui_power.h"
#include "app_menu_core.h"
#include "app_menu.h"
#include "app_menu_api.h"
#include "app_menu_micro.h"
#include "app_menu_tab.h"
#include "app_menu_event.h"
#include "app_audio_rec.h"
#include "cardlink.h"
#include "storage.h"
#include "key_scan.h"
#include "ptr_func.h"
#include "copydisk.h"
#include "main.h"
#include "app_still_view.h"
#include "app_still_play.h"
#include "sp1k_aud_api.h"
#include "sp1k_pb_api.h"
#include "sp1k_osd_api.h"
#include "sp1k_snap_api.h"
#include "sp1k_hal_api.h"
#include "sp1k_util_api.h"
#include "sp1k_hal_api.h"
#include "sp1k_disp_api.h"
#include "sp1k_vfs_api.h"
#include "dos32.h"
#include "app_audio_play.h"
#include "Uiflow.h"
#include "sp1k_dps_api.h"
/**************************************************************************
 *                      G L O B A L    C O N S T A N T                    *
 **************************************************************************/

/**************************************************************************
 *                         G L O B A L    D A T A                         *
 **************************************************************************/
UINT8 code rtc_init[3]={1, 2, 0};
UINT8 code rtc_left[3][6]={{2, 5, 1, 0, 3, 4}, {1, 2, 5, 0, 3, 4}, {5, 0, 1, 2, 3, 4}};
UINT8 code rtc_right[3][6]={{3, 2, 0, 4, 5, 1}, {3, 0, 1, 4, 5, 2}, {1, 2, 3, 4, 5, 0}};

/**************************************************************************
 *               F U N C T I O N    D E C L A R A T I O N S               *
 **************************************************************************/

/**************************************************************************
 *                 E X T E R N A L    R E F E R E N C E S                 *
 **************************************************************************/
extern void menuDayItemCheck(UINT8 item, UINT8 key);
extern void menuDynamicFontInit(void);
extern void menuDynamicOsdExit(void);

extern UINT32 menuPosBackup;
extern SIMAGE xdata pbFile;
extern xdata struct DATESTC	DATEINFO;
extern xdata UINT8 voicePlayFlag;
extern UINT8 PrintStatus;
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
#if PHOTO_FRAME_PV
static UINT8 CurrentFrame=0;
#endif
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */
//extern UINT8 xdata OsdMaxX, OsdMaxY;
//-----------------------------------------------------------------------------
//appMenu
//-----------------------------------------------------------------------------
void appMenu (UINT8 msg) USING_0
{
	UINT8 layer;
	UINT8 item;
	UINT8 sel = 0;
	UINT8 subItem=0;
	UINT32 menuPos=0;
	PBFile_t FileInfo;//jintao.liu 2008-3-27 mantis:22012
//	powerBatLv_t batlv;
	static UINT8 hotKeyFlag = 0;
	static UINT8 preMsg = SP1K_MSG_NULL;
	uiPara_t* puiPara = appUiParaGet();
	printf("menu msg=%bu\n", msg);

	if (preMsg == SP1K_MSG_KEY_PRESS_S2 && msg == SP1K_MSG_KEY_PRESS_OK) {
		//Enter the state of version show
		hotKeyFlag = 1;
	} else if (hotKeyFlag && preMsg == SP1K_MSG_KEY_RELEASE_OK) {
		//Exit the state of version show 		
		hotKeyFlag = 0;
		menuProcDisp();
		return;
	}

	menuPos = menuProcCurrPosGet();

	switch (msg) {
		case SP1K_MSG_STATE_INIT:
		//printf("menu init\n");
		menuInit();
		menuProcDisp();
		break;

    	case SP1K_MSG_KEY_PRESS_S1:
		//printf("S1 on menu\n");
		break;

    	case SP1K_MSG_KEY_PRESS_S2:
		break;
		
//1 PressMenu
    	case SP1K_MSG_KEY_PRESS_MENU:
		layer = menuProcLayerGet();
		item = menuProcCurrItemGet(layer);
		//Dragon add for effect@20080310 begin
		if ((menuPos >= MENU_MARK_PV_EFFECT_FIRST) && (menuPos < MENU_MARK_PV_EFFECT_OVER))
		{
			appEffectSet(puiPara->ImageEffect);
		}
		//Dragon add for effect@20080310 end
		//Dragon add for WB@20080315 begin
		else if (((menuPos >= MENU_MARK_WB_FIRST) && (menuPos < MENU_MARK_WB_OVER))||
			((menuPos >= MENU_MARK_VIDEO_WB_FIRST) && (menuPos <MENU_MARK_VIDEO_WB_OVER)))
		{
			appWBSet(puiPara->WBMode);
		}
		//Dragon add for WB@20080315 end
		//Dragon add for Sound@20080325 begin
		else if((menuPos>=MENU_MARK_SOUND_FIRST)&&(menuPos<MENU_MARK_SOUND_OVER))
		{
			voicePlayFlag=TRUE;
			appVoicePlay(SP1K_MSG_UNKNOWN,VOICE_TYPE_BEEP, VOICE_PLAYLEVLE_HIGH);
		}
		//Dragon add for Sound@20080325 end
		//Dragon add for EV@200800403 begin
		
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
#if PHOTO_FRAME_PV
		else if ((menuPos >= MENU_MARK_PV_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PV_PHOTO_FRAME_OVER))
		{
			//sp1kPvPhotofrmEnable(0);
			appPvPhotoFrameSet(CurrentFrame);	
			menuProcParent();
			menuProcDisp();
		}
#endif

#if PHOTO_FRAME_PB
		else if ((menuPos >= MENU_MARK_PB_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PB_PHOTO_FRAME_OVER))
		{

			sp1kHalGprmCpy(pbDispBuffGet(0), PB_DECODE_WIDTH, PB_DECODE_HEIGHT, 0, 0, 	pbDispBuffGet(1), PB_DECODE_WIDTH, PB_DECODE_HEIGHT, 0, 0,PB_DECODE_WIDTH, PB_DECODE_HEIGHT,0, 1);
			menuProcParent();
			menuProcDisp();
		}
#endif
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */


		//jintao.liu 2008-6-17 add for rotation
		else if (menuPos == MENU_MARK_ROTATE_ROTATE || menuPos == MENU_MARK_ROTATE_SAVE || \
					menuPos == MENU_MARK_ROTATE_BACK)
		{
			sp1kPbParamSet(PB_PARAM_ROT, 0);    //clear  
			sp1kPbSingleImgPlay(DOS_FileIndexGet(pbFile.dwIndex));
			menuProcParent();
			menuProcDisp();
		}
		//jintao.liu 2008-6-17 add for rotation end
		
		#if 1//2008-7-14 mantis #28130
		else if((menuPos == MENU_MARK_DELETE_SINGLE_YES) || (menuPos == MENU_MARK_DELETE_SINGLE_NO))
		{
			menuProcParent ();
			menuProcDisp();
			//break;
		}
		#endif

		
		else if((menuPos>=MENU_MARK_EXPOSURE_FIRST)&&(menuPos<MENU_MARK_EXPOSURE_OVER))
		{
			appEVSet(puiPara->AEMode);
		}
		//Dragon add for EV@20080403 end
		if ((layer == MENU_LAYER_0) || (layer == MENU_LAYER_1))
		{
			menuExit();
		}	
		else if (layer == MENU_LAYER_2)
		{
			menuProcParent ();
			menuProcDisp();
		}

		break;
		
//1 PressUp
    	case SP1K_MSG_KEY_PRESS_UP:
		layer = menuProcLayerGet();
		item = menuProcCurrItemGet(layer);
		if ((menuPos >= MENU_MARK_EXPOSURE_FIRST) && (menuPos < MENU_MARK_EXPOSURE_OVER))
		{
		}
		else if ((menuPos >= MENU_MARK_PV_EFFECT_FIRST) && (menuPos < MENU_MARK_PV_EFFECT_OVER))
		{
			menuProcMoveUp ();
			menuProcDisp();
			item = menuProcCurrItemGet(layer);
			appEffectSet(item);
		}
		//Dragon add for sound@20080325 begin
		else if((menuPos==MENU_MARK_DELETE_SINGLE_NO)||(menuPos==MENU_MARK_DELETE_SINGLE_YES))
		{
			UINT8 Xoffset = 0;
			if(appPanelTypeGet() == 0) {
				Xoffset = 1;
			}	
			menuProcMoveUp ();
			menuProcDisp();
			uiUpdateOSDPbFileNum();
			uiUpdateOSDPbType(0 + Xoffset, 0 , 5);
		}
		else if((menuPos>=MENU_MARK_SOUND_FIRST)&&(menuPos<MENU_MARK_SOUND_OVER))
		{
			appVoicePlay(SP1K_MSG_UNKNOWN,VOICE_TYPE_BEEP, VOICE_PLAYLEVLE_HIGH);
			menuProcMoveUp ();
			menuProcDisp();
		}
		//Dragon add for sound@20080325 end
		else if (((menuPos >= MENU_MARK_WB_FIRST) && (menuPos < MENU_MARK_WB_OVER))||
			((menuPos >= MENU_MARK_VIDEO_WB_FIRST) && (menuPos <MENU_MARK_VIDEO_WB_OVER)))
		{
			menuProcMoveUp ();
			menuProcDisp();
			item = menuProcCurrItemGet(layer);
			appWBSet(item);
		}
		else if ((menuPos >= MENU_MARK_RTC_FIRST) && (menuPos < MENU_MARK_RTC_OVER))
		{
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcMoveDown();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuProcParaSet(layer, item);
				menuProcParent();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuDayItemCheck(item, SP1K_MSG_KEY_PRESS_UP);
				menuProcDisp();
			}
		}
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
#if PHOTO_FRAME_PV
		else if ((menuPos >= MENU_MARK_PV_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PV_PHOTO_FRAME_OVER))
		{
			menuProcMoveUp();
			item = menuProcCurrItemGet(layer);
			if (item != PRV_PHOTO_FRAME_OFF) {
				sp1kOsdClear(ID_ICON_NONE, 0);
				sp1kOsdSelWinSet(-1, -1, -1, -1, 0, -1);
			} else {
				menuProcDisp();
			}
			appPvPhotoFrameSet(item);
		}
#endif	


#if PHOTO_FRAME_PB
		else if ((menuPos >= MENU_MARK_PB_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PB_PHOTO_FRAME_OVER))
		{
			menuProcMoveUp();
			item = menuProcCurrItemGet(layer);
			if (item != PRV_PHOTO_FRAME_OFF) {
				sp1kOsdClear(ID_ICON_NONE, 0);
				sp1kOsdSelWinSet(-1, -1, -1, -1, 0, -1);
			} else {
				menuProcDisp();
			}
			appPbPhotoFrameSet(item,0);
		}
#endif	
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */

		else if ((menuPos == MENU_MARK_STILL) || (menuPos == MENU_MARK_VIDEO) || (menuPos == MENU_MARK_AUDIO) || (menuPos == MENU_MARK_PLAYBACK) || (menuPos == MENU_MARK_SETUP) || (menuPos == MENU_MARK_CALIBRATION_MENU))
		{
			if (menuProcChild (0) == SUCCESS)
				menuProcMoveUp();
			menuProcDisp();
		}
		else if (layer == 1)
		{
			menuProcMoveUp ();
			if (item <= menuProcCurrItemGet(layer))
				menuProcParent ();
			menuProcDisp();
		}
		else
		{
			menuProcMoveUp ();
			menuProcDisp();
		}
		break;

		case SP1K_MSG_KEY_REPEATE_UP:
		layer = menuProcLayerGet();
		item = menuProcCurrItemGet(layer);
		if ((menuPos >= MENU_MARK_RTC_FIRST) && (menuPos < MENU_MARK_RTC_OVER))
		{
			if (item == 5)
				break;

			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcMoveDown();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuProcParaSet(layer, item);
				menuProcParent();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuDayItemCheck(item, SP1K_MSG_KEY_PRESS_UP);
				menuProcDisp();
			}
		}
		break;
		
//1 PressDown
    	case SP1K_MSG_KEY_PRESS_DOWN:
		layer = menuProcLayerGet();
		item = menuProcCurrItemGet(layer);
		if ((menuPos >= MENU_MARK_EXPOSURE_FIRST) && (menuPos < MENU_MARK_EXPOSURE_OVER))
		{
		}
		//Dragon add for sound@20080325 begin
		else if((menuPos >= MENU_MARK_SOUND_FIRST) && (menuPos < MENU_MARK_SOUND_OVER))
		{
			appVoicePlay(SP1K_MSG_UNKNOWN,VOICE_TYPE_BEEP, VOICE_PLAYLEVLE_HIGH);
			menuProcMoveDown ();
			menuProcDisp();
		}
		//Dragon add for sound@20080325 end
		else if((menuPos==MENU_MARK_DELETE_SINGLE_NO)||(menuPos==MENU_MARK_DELETE_SINGLE_YES))
		{
			UINT8 Xoffset = 0;
			if(appPanelTypeGet() == 0) {
				Xoffset = 1;
			}						
			menuProcMoveDown ();
			menuProcDisp();
			uiUpdateOSDPbFileNum();
			uiUpdateOSDPbType(0 + Xoffset, 0 , 5);
		}
		else if ((menuPos >= MENU_MARK_PV_EFFECT_FIRST) && (menuPos < MENU_MARK_PV_EFFECT_OVER))
		{
			menuProcMoveDown();
			menuProcDisp();
			item = menuProcCurrItemGet(layer);
			appEffectSet(item);
		}
		else if (((menuPos >= MENU_MARK_WB_FIRST) && (menuPos < MENU_MARK_WB_OVER))||
			((menuPos >= MENU_MARK_VIDEO_WB_FIRST) && (menuPos <MENU_MARK_VIDEO_WB_OVER)))
		{
			menuProcMoveDown();
			menuProcDisp();
			item = menuProcCurrItemGet(layer);
			appWBSet(item);
		}
		else if ((menuPos >= MENU_MARK_RTC_FIRST) && (menuPos < MENU_MARK_RTC_OVER))
		{
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcMoveUp();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuProcParaSet(layer, item);
				menuProcParent();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuDayItemCheck(item, SP1K_MSG_KEY_PRESS_DOWN);
				menuProcDisp();
			}
		}
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
#if PHOTO_FRAME_PV
		else if ((menuPos >= MENU_MARK_PV_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PV_PHOTO_FRAME_OVER))
		{
			menuProcMoveDown();
			item = menuProcCurrItemGet(layer);
			if (item != PRV_PHOTO_FRAME_OFF) {
				sp1kOsdClear(ID_ICON_NONE, 0);
				sp1kOsdSelWinSet(-1, -1, -1, -1, 0, -1);
			} else {
				menuProcDisp();
			}
			appPvPhotoFrameSet(item);
		}
#endif

#if PHOTO_FRAME_PB
		else if ((menuPos >= MENU_MARK_PB_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PB_PHOTO_FRAME_OVER))
		{
			menuProcMoveDown();
			item = menuProcCurrItemGet(layer);
			if (item != PRV_PHOTO_FRAME_OFF) {
				sp1kOsdClear(ID_ICON_NONE, 0);
				sp1kOsdSelWinSet(-1, -1, -1, -1, 0, -1);
			} else {
				menuProcDisp();
			}
			appPbPhotoFrameSet(item,0);
		}
#endif
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */

		else if ((menuPos == MENU_MARK_STILL) || (menuPos == MENU_MARK_VIDEO) || (menuPos == MENU_MARK_AUDIO) || (menuPos == MENU_MARK_PLAYBACK) || (menuPos == MENU_MARK_SETUP) || (menuPos == MENU_MARK_CALIBRATION_MENU))
		{
			menuProcChild (0);
			menuProcDisp();
		}
		#if 0
		else if ((menuPos == MENU_MARK_STILL_LAST) || (menuPos == MENU_MARK_VIDEO_LAST) || (menuPos == MENU_MARK_AUDIO_LAST) || (menuPos == MENU_MARK_PLAYBACK_LAST) || (menuPos == MENU_MARK_SETUP_LAST))
		{
			menuProcParent ();
			menuProcDisp();
		}
		#else
		else if (layer == 1)
		{
			menuProcMoveDown ();
			if (item >= menuProcCurrItemGet(layer))
				menuProcParent ();
			menuProcDisp();
		}
		#endif
		else
		{
			menuProcMoveDown ();
			menuProcDisp();
		}
		break;

		case SP1K_MSG_KEY_REPEATE_DOWN:
		layer = menuProcLayerGet();
		item = menuProcCurrItemGet(layer);
		if ((menuPos >= MENU_MARK_RTC_FIRST) && (menuPos < MENU_MARK_RTC_OVER))
		{
			if (item == 5)
				break;

			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcMoveUp();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuProcParaSet(layer, item);
				menuProcParent();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuDayItemCheck(item, SP1K_MSG_KEY_PRESS_DOWN);
				menuProcDisp();
			}
		}
		break;
		
//1 PressLeft
    	case SP1K_MSG_KEY_PRESS_LEFT:
		layer = menuProcLayerGet();
		item = menuProcCurrItemGet(layer);
		if ((menuPos >= MENU_MARK_SLIDE_FIRST) && (menuPos < MENU_MARK_SLIDE_OVER)) 
		{
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcMoveUp();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuProcParaSet(layer, item);
				menuProcParent();
				menuProcDisp();
			}
		}
		//Dragon add for sound@20080325 begin
		else if((menuPos >= MENU_MARK_SOUND_FIRST) && (menuPos < MENU_MARK_SOUND_OVER))
		{
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcMoveUp();
				layer = menuProcLayerGet();
				appVoicePreview(item, menuProcCurrItemGet(layer));
				item = menuProcCurrItemGet(layer);
				menuProcParaSet(layer, item);
				sp1kSnapParamSet( SP1K_SNAP_PARAM_SHUTTER_SOUND_OPT,((~(puiPara->ShutterSound))&0x01)); 	
				menuProcParent();
				menuProcDisp();
			}
		}
		//Dragon add for sound@20080325 end
		//Dragon add for effect@20080310 begin
		else if ((menuPos >= MENU_MARK_PV_EFFECT_FIRST) && (menuPos < MENU_MARK_PV_EFFECT_OVER))
		{
			appEffectSet(puiPara->ImageEffect);
			menuProcParent ();
			menuProcDisp();
		}
		//Dragon add for effect@20080310 end
		//Dragon add for WB@20080315 begin
		else if (((menuPos >= MENU_MARK_WB_FIRST) && (menuPos < MENU_MARK_WB_OVER))||
			((menuPos >= MENU_MARK_VIDEO_WB_FIRST) && (menuPos <MENU_MARK_VIDEO_WB_OVER)))
		{
			appWBSet(puiPara->WBMode);
			menuProcParent ();
			menuProcDisp();
		}
		//Dragon add for WB@20080315 end
		else if ((menuPos >= MENU_MARK_EXPOSURE_FIRST) && (menuPos < MENU_MARK_EXPOSURE_OVER))
		{
			menuProcMoveUp();
			layer = menuProcLayerGet();
			item = menuProcCurrItemGet(layer);
			//------>menuProcParaSet(layer, item);
			menuProcDisp();
			appEVSet(item);
		}
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
#if PHOTO_FRAME_PV
		else if ((menuPos >= MENU_MARK_PV_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PV_PHOTO_FRAME_OVER))
		{
			//sp1kPvPhotofrmEnable(0);
			appPvPhotoFrameSet(CurrentFrame);				
			menuProcParent();
			menuProcDisp();
		}
#endif

#if PHOTO_FRAME_PB
		else if ((menuPos >= MENU_MARK_PB_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PB_PHOTO_FRAME_OVER))
		{
			//sp1kPvPhotofrmEnable(0);
			sp1kHalGprmCpy(pbDispBuffGet(0), PB_DECODE_WIDTH, PB_DECODE_HEIGHT, 0, 0, 	pbDispBuffGet(1), PB_DECODE_WIDTH, PB_DECODE_HEIGHT, 0, 0,PB_DECODE_WIDTH, PB_DECODE_HEIGHT,0, 1);
			menuProcParent();
			menuProcDisp();
		}
#endif
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */

		else if ((menuPos >= MENU_MARK_RTC_FIRST) && (menuPos < MENU_MARK_RTC_OVER))
		{
			menuProcParent();
			menuProcChild (rtc_left[puiPara->DateStyle][item]);
			menuProcDisp();
		}
		else if ((menuPos == MENU_MARK_STILL) || (menuPos == MENU_MARK_VIDEO) || (menuPos == MENU_MARK_AUDIO) || (menuPos == MENU_MARK_PLAYBACK))
		{
			menuProcCurrPosSet(MENU_MARK_SETUP);
			menuProcDisp();
		}
		else if (menuPos == MENU_MARK_SETUP)
		{
			menuInit();
			menuProcDisp();
		}
		else if((menuPos==MENU_MARK_DELETE_SINGLE_NO)||(menuPos==MENU_MARK_DELETE_SINGLE_YES))
		{
			UINT8 Xoffset = 0;

			if (appPreStateGet(0) == APP_STATE_MUTI_PLAY) {
				break;
			}
			if(appPanelTypeGet() == 0) {
				Xoffset = 1;
			}	
			appStillPlayNext(0);
			menuProcDisp();
			appPbFileInfoUpdate();
			uiUpdateOSDPbFileNum();
			uiUpdateOSDPbType(0 + Xoffset, 0 , 5);
		}
		else
		{
			if (layer == MENU_LAYER_2)
			{
				menuProcParent ();
				menuProcDisp();
			}
		}
		break;
		
//1 PressRight
    	case SP1K_MSG_KEY_PRESS_RIGHT:
		layer = menuProcLayerGet();
		item = menuProcCurrItemGet(layer);
		
		if (menuPos == MENU_MARK_SLIDE_START)
		{
			appMenuEvent_SlideShowStart();
		}
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
		//jintao.liu 2008-6-16 add for photo frame
#if PHOTO_FRAME_PB
		else if (menuPos == MENU_MARK_PB_PHOTO_FRAME)
		{
			//break;
			HAL_copy(
				 pbDispBuffGet(1), // Active buffer    //display show this
				 PB_DECODE_WIDTH, PB_DECODE_HEIGHT, 0, 0,
				 pbDispBuffGet(0), //inactive buffer   //store the source display data
				 PB_DECODE_WIDTH, PB_DECODE_HEIGHT, 0, 0,
				 PB_DECODE_WIDTH, PB_DECODE_HEIGHT,
				 0,
				 1
			);
			
			menuProcChild (0);
			menuProcDisp();
		}
#endif
		//jintao.liu 2008-6-16 add for photo frame end
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */

		else if ((menuPos == MENU_MARK_SLIDE_INTERVAL) || (menuPos == MENU_MARK_SLIDE_REPEAT)) 
		{
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcMoveDown();
				layer = menuProcLayerGet();
				item = menuProcCurrItemGet(layer);
				menuProcParaSet(layer, item);
				menuProcParent();
				menuProcDisp();
			}
		}
		//Dragon add for sound@20080325 begin
		else if ((menuPos >= MENU_MARK_SOUND_FIRST) && (menuPos < MENU_MARK_SOUND_OVER))
		{
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
		 		menuProcChild (sel);
				menuProcMoveDown();
				layer = menuProcLayerGet();
				appVoicePreview(item, menuProcCurrItemGet(layer));
				item = menuProcCurrItemGet(layer);
				menuProcParaSet(layer, item);
				sp1kSnapParamSet( SP1K_SNAP_PARAM_SHUTTER_SOUND_OPT,((~(puiPara->ShutterSound))&0x01)); 
				menuProcParent();
				menuProcDisp();
			}
		}
		//Dragon add for sound@20080325 end
		else if (menuPos == MENU_MARK_RTC_INIT)
		{
			sp1kHalReadRTC(&DATEINFO);
			puiPara->rtcDay=DATEINFO.Day-1;
			puiPara->rtcHour=DATEINFO.Hour;
			puiPara->rtcMinute=DATEINFO.Minute;
			puiPara->rtcMonth=DATEINFO.Month-1;
			puiPara->rtcYear=DATEINFO.Year;
			menuProcChild (rtc_init[puiPara->DateStyle]);
			menuProcDisp();
		}
		else if ((menuPos >= MENU_MARK_EXPOSURE_FIRST) && (menuPos < MENU_MARK_EXPOSURE_OVER))
		{
			menuProcMoveDown();
			layer = menuProcLayerGet();
			item = menuProcCurrItemGet(layer);
			//---->menuProcParaSet(layer, item);
			menuProcDisp();
			appEVSet(item);
		}
		else if ((menuPos >= MENU_MARK_RTC_FIRST) && (menuPos < MENU_MARK_RTC_OVER))
		{
			menuProcParent();
			menuProcChild (rtc_right[puiPara->DateStyle][item]);
			menuProcDisp();
		}
		else if ((menuPos == MENU_MARK_STILL) || (menuPos == MENU_MARK_VIDEO) || (menuPos == MENU_MARK_AUDIO) || (menuPos == MENU_MARK_PLAYBACK))
		{
			menuProcCurrPosSet(MENU_MARK_SETUP);
			menuProcDisp();
		}
		else if (menuPos == MENU_MARK_SETUP)
		{
			menuInit();
			menuProcDisp();
		}
		//Dragon add for sound@20080325 begin
		else if (menuPos== MENU_MARK_SETUP_SOUND)
		{
			voicePlayFlag=FALSE;
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcDisp();
			}
		}
		//Dragon add for sound@20080325 end
		else if (menuPos == MENU_MARK_DELETE_SINGLE)
		{
			UINT8 Xoffset = 0;
			if(appPanelTypeGet() == 0) {
				Xoffset = 1;
			}	
			sel = menuProcParaGet(layer, item);
			menuProcChild (sel);
			menuProcDisp();	
			appPbFileInfoUpdate();
			uiUpdateOSDPbFileNum();
			uiUpdateOSDPbType(0 + Xoffset, 0 , 5);
		}
		else if((menuPos==MENU_MARK_DELETE_SINGLE_NO)||(menuPos==MENU_MARK_DELETE_SINGLE_YES))
		{
			UINT8 Xoffset = 0;
			
			if (appPreStateGet(0) == APP_STATE_MUTI_PLAY) {
				break;
			}
			if(appPanelTypeGet() == 0) {
				Xoffset = 1;
			}	
			appStillPlayNext(1);
			appPbFileInfoUpdate();
			menuProcDisp();
			uiUpdateOSDPbFileNum();
			uiUpdateOSDPbType(0 + Xoffset, 0 , 5);
		}
		else if(menuPos == MENU_MARK_STARTUP_IMAGE_YES)
		{
			appMenuEvent_StartUpImgSet();
		}
		else
		{
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcDisp();
			}
		}
		break;
		
//1 PressOk
    	case SP1K_MSG_KEY_PRESS_OK:
		if (hotKeyFlag) {
			#if 0
			osMsgPost(SP1K_MSG_STATE_TO_CAL_MENU);
			#else
			appMenuEvent_VerShow();
			#endif
			break;
		}
		case SP1K_MSG_KEY_PRESS_F1:
		layer = menuProcLayerGet();
		item = menuProcCurrItemGet(layer);

		if((menuPos == MENU_MARK_TV_NTSC) || (menuPos == MENU_MARK_TV_PAL))
		{
			menuProcParaSet(layer, item);
			if(0 == appPanelTypeGet())//TV
			{
				appPanelStatusSet(0xFF);//jintao.liu test
			}
			menuProcParent ();
			menuProcDisp();

			/*
			menuProcParaSet(layer, item);
			appPanelStatusSet(0xFF);
			menuProcParent ();
			menuProcDisp();*/
		}

/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
		else if(menuPos == MENU_MARK_PICTBRIDGE)
		{
       		PrintStatus= DPS_TO_CON_PRINT;
			puiPara->USBMode = USB_SIDC;
			G_CameraOptions.Storage = K_UIOPTION_STORAGE_SIDC;
			G_UIStatus = K_UISTATUS_USBMODE_MASS;
			sp1k_dps_paramSet(DPS_PARAM_SidcSurportImageCountMax,0);
			menuExit();
			osMsgPost(SP1K_MSG_STATE_TO_STILL_PLAY);
		}
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */
		
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
		//2008-6-16 add for photo frame
#if PHOTO_FRAME_PB
		else if ((menuPos >= MENU_MARK_PB_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PB_PHOTO_FRAME_OVER))
		{
			item = menuProcCurrItemGet(layer);
			appMenuEvent_PbFrameSave(item);//modify for mantis #36999 
		}
#endif
		//2008-6-16 add for photo frame end
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */


		//2008-6-17 add for rotation
		else if (menuPos == MENU_MARK_ROTATE_ROTATE || menuPos == MENU_MARK_ROTATE_SAVE || \
					menuPos == MENU_MARK_ROTATE_BACK)
		{
			appMenuEvent_ImgRotate(menuPos);
		}
		//2008-6-17 add for rotation end


		else if((menuPos >= MENU_MARK_LANGUAGE_FIRST) && (menuPos < MENU_MARK_LANGUAGE_OVER))
		{
			menuProcParaSet(layer, item);
			sp1kOsdLoad();
			menuProcParent ();
			menuProcDisp();
		}
		//Dragon add for effect@20080310 begin
		else if ((menuPos >= MENU_MARK_PV_EFFECT_FIRST) && (menuPos < MENU_MARK_PV_EFFECT_OVER))
		{
			menuProcParaSet(layer, item);
			menuProcParent ();
			menuProcDisp();
		}
		//Dragon add for effect@20080310 end
		//Dragon add for wb@20080317 begin
		else if (((menuPos >= MENU_MARK_WB_FIRST) && (menuPos < MENU_MARK_WB_OVER))||
			((menuPos >= MENU_MARK_VIDEO_WB_FIRST) && (menuPos <MENU_MARK_VIDEO_WB_OVER)))
		{
			menuProcParaSet(layer, item);
			menuProcParent ();
			menuProcDisp();
			
		}
		//Dragon add for wb@20080317 end
		//Dragon add for Sound@20080325 begin
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
#if PHOTO_FRAME_PV
		else if ((menuPos >= MENU_MARK_PV_PHOTO_FRAME_FIRST) && (menuPos < MENU_MARK_PV_PHOTO_FRAME_OVER))
		{
			//uiPara_t* pPara;
			if (item == PRV_PHOTO_FRAME_OFF) {
				appPvPhotoFrameSet(item);
			}
			CurrentFrame=item;
			menuProcParaSet(layer, item);
			menuExit();
			//pPara = appUiParaGet();
			//printf("frame is %bu\n", pPara->PhotoFrame);
		}
#endif
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */
		else if((menuPos>=MENU_MARK_SOUND_FIRST)&&(menuPos<MENU_MARK_SOUND_OVER))
		{
			voicePlayFlag=TRUE;
			appVoicePlay(SP1K_MSG_UNKNOWN,VOICE_TYPE_BEEP, VOICE_PLAYLEVLE_HIGH);
			menuProcParent ();
			menuProcDisp();
		}
		//Dragon add for Sound@20080325 end
		else if (menuPos == MENU_MARK_DELETE_SINGLE)
		{
			UINT8 Xoffset = 0;
			if(appPanelTypeGet() == 0) {
				Xoffset = 1;
			}	
			sel = menuProcParaGet(layer, item);
			menuProcChild (sel);
			menuProcDisp();	
			appPbFileInfoUpdate();
			uiUpdateOSDPbFileNum();
			uiUpdateOSDPbType(0 + Xoffset, 0 , 5);
		}
		else if (menuPos == MENU_MARK_DELETE_SINGLE_YES)
		{
			appMenuEvent_DeleteSingle();
		}
		else if (menuPos == MENU_MARK_DELETE_ALL_YES)
		{			
			appMenuEvent_DeleteAll();
		}
		else if (menuPos == MENU_MARK_PROTECT_SINGLE_YES)
		{
			if(1 == appSDProtectStatusGet())//jintao.liu 2008-5-6 sd lock
			{
				uiOsdDialogDisp(ID_STR_CARD_LOCKED_, 1000);
				menuProcDisp();
				return;
			}
			sp1kPbFileInfoGet(sp1kPbFileIndexByOrderGet(pbFile.dwIndex), &FileInfo);
			if((FileInfo.FileAttrib & 0x03) == 1)			
				appFileAttrSet(pbFile.dwIndex, 0, SP1K_FILE_PROC_ONE);
			else
			appFileAttrSet(pbFile.dwIndex, 1, SP1K_FILE_PROC_ONE);
			menuProcParent ();
			menuProcDisp();
		}
		else if (menuPos == MENU_MARK_PROTECT_ALL_YES)
		{			
			if(1 == appSDProtectStatusGet())//jintao.liu 2008-5-6 sd lock
			{
				uiOsdDialogDisp(ID_STR_CARD_LOCKED_, 1000);
				menuProcDisp();
				return;
			}
			appUiBusyWait(250, 1);				
			appFileAttrSet(pbFile.dwIndex, 1, SP1K_FILE_PROC_ALL);
			appUiBusyExit();
			
			menuExit();	
		}
		else if (menuPos == MENU_MARK_UNPROTECT_ALL_YES)
		{			
			if(1 == appSDProtectStatusGet())//jintao.liu 2008-5-6 sd lock
			{
				uiOsdDialogDisp(ID_STR_CARD_LOCKED_, 1000);
				menuProcDisp();
				return;
			}
			appUiBusyWait(250, 1);
			appFileAttrSet(pbFile.dwIndex, 0, SP1K_FILE_PROC_ALL);
			appUiBusyExit();
			
			menuExit();	
		}

#if CP_TO_CARD_EN//jintao.liu 2008-6-17 add to mask cp to card
		else if (menuPos == MENU_MARK_COPY2CARD_SINGLE_YES)
		{	
			if(1 == appSDProtectStatusGet())//jintao.liu 2008-5-6 sd lock
			{
				uiOsdDialogDisp(ID_STR_CARD_LOCKED_, 1000);
				menuProcDisp();
				return;
			}
			appCopy2Card(SP1K_FILE_PROC_ONE, K_Copy_Nand2Card);
			menuProcParent ();
			menuProcDisp();
		}
		else if (menuPos == MENU_MARK_COPY2CARD_ALL_YES)
		{		
			if(1 == appSDProtectStatusGet())//jintao.liu 2008-5-6 sd lock
			{
				uiOsdDialogDisp(ID_STR_CARD_LOCKED_, 1000);
				menuProcDisp();
				return;
			}
			appUiBusyWait(250, 1);
			appCopy2Card(SP1K_FILE_PROC_ALL, K_Copy_Nand2Card);		
			appUiBusyExit();
			
			menuExit();	
		}
#endif

		else if ((menuPos >= MENU_MARK_PB_EFFECT_FIRST) && (menuPos < MENU_MARK_PB_EFFECT_OVER)) {
			appMenuEvent_ImgEffect(menuPos);
		}
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
		else if ((menuPos >= MENU_MARK_PB_DISTORTION_FIRST) && (menuPos < MENU_MARK_PB_DISTORTION_OVER)){
			appMenuEvent_ImgEffect(menuPos);
		}
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */		
		else if (menuPos == MENU_MARK_SLIDE_START) {
			appMenuEvent_SlideShowStart();
		} 
		else if ((menuPos == MENU_MARK_SLIDE_INTERVAL) || (menuPos == MENU_MARK_SLIDE_REPEAT)) {
			menuProcParent ();
			menuProcDisp();		
		}
		else if ((menuPos >= MENU_MARK_SOUND_FIRST) && (menuPos < MENU_MARK_SOUND_OVER))
		{
			menuProcParent ();
			menuProcDisp();
		}
		else if (menuPos == MENU_MARK_MEMO_ADD)
		{
			appMenuEvent_VoiceMemoAdd();
		}
		else if (menuPos == MENU_MARK_MEMO_DELETE)
		{
			appMenuEvent_VoiceMemoDel();
		}
		else if (menuPos == MENU_MARK_FORMAT_YES)
		{
			//jintao.liu 2008-5-6 first detect sd lock here
			if(1 == appSDProtectStatusGet())
			{
				uiOsdDialogDisp(ID_STR_CARD_LOCKED_, 1000);
				menuExit();	
				return;
			}
			
			appUiBusyWait(250, 1);
			STORAGE_Format(0xC0);//format
			M_Card_Initialize(1);// initialization
			G_USR_FileIndex = 1; //DCF Init
			appUiBusyExit();
			menuExit();	
			uiRemainPixInit();
		}		
		else if (menuPos == MENU_MARK_RTC_INIT)
		{
			sp1kHalReadRTC(&DATEINFO);
			puiPara->rtcDay=DATEINFO.Day-1;
			puiPara->rtcHour=DATEINFO.Hour;
			puiPara->rtcMinute=DATEINFO.Minute;
			puiPara->rtcMonth=DATEINFO.Month-1;
			puiPara->rtcYear=DATEINFO.Year;
			menuProcChild (rtc_init[puiPara->DateStyle]);
			menuProcDisp();
		}
		else if ((menuPos >= MENU_MARK_EXPOSURE_FIRST) && (menuPos < MENU_MARK_EXPOSURE_OVER) )
		{
			layer = menuProcLayerGet();
			item = menuProcCurrItemGet(layer);
			menuProcParaSet(layer, item);
			appEVSet(item);
			menuProcParent ();
			menuProcDisp();
		}
		else if((menuPos >= MENU_MARK_RTC_FIRST) && (menuPos < MENU_MARK_RTC_OVER))
		{
			DATEINFO.Day=puiPara->rtcDay+1;
			DATEINFO.Hour=puiPara->rtcHour;
			DATEINFO.Minute=puiPara->rtcMinute;
			DATEINFO.Month=puiPara->rtcMonth+1;
			DATEINFO.Year=puiPara->rtcYear;
			menuProcParent ();
			menuProcDisp();
			sp1kHalWriteRTC(&DATEINFO);
		}
		else if (menuPos == MENU_MARK_RESET_YES)
		{
			appUiParaInit(PARA_INIT_WITH_DEF);
/* ------ Note: Demo code zone start flag, don't modify or delete this line!!! ------ */
			appPvPhotoFrameSet(PRV_PHOTO_FRAME_OFF); //wangdong@2009.1.15 add  for mantis 0034652	
/* ------ Note: Demo code zone end flag, don't modify or delete this line!!! ------ */		
			sp1kOsdLoad(); // Mantis 0034619 
			menuProcParent ();
			menuProcDisp();
			appVolumeSet();
		}
		else if (menuPos >= MENU_MARK_RESIZE_FIRST && menuPos <= MENU_MARK_RESIZE_OVER)
		{
			appMenuEvent_ImgResize(menuPos);
		}
		else if(menuPos == MENU_MARK_STARTUP_IMAGE_YES)
		{
			appMenuEvent_StartUpImgSet();
		}
		else if(menuPos==MENU_MARK_SETUP_SOUND)
		{
			voicePlayFlag=FALSE;
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcDisp();
			}
			else if (layer >= MENU_LAYER_2)
			{
				menuProcParaSet(layer, item);
				menuProcParent ();
				menuProcDisp();
			}
		}
		else
		{
			subItem = menuProcSubItemGet(layer, item);
			if (subItem > 0)
			{
				sel = menuProcParaGet(layer, item);
				menuProcChild (sel);
				menuProcDisp();
			}
			else if (layer >= MENU_LAYER_2)
			{
				menuProcParaSet(layer, item);
				menuProcParent ();
				menuProcDisp();
			}
		}
		break;

    	case SP1K_MSG_KEY_PRESS_TELE:
		break;
    	case SP1K_MSG_KEY_PRESS_WIDE:
		break;
    	case SP1K_MSG_KEY_PRESS_DISP:
		break;
		case SP1K_MSG_CARD_PLUG_IN:

			#if 0//old method
				appStorageMount(K_MEDIA_SDF);
				uiRemainPixInit();
				menuExit();	
				//osMsgPost(SP1K_MSG_STATE_INIT);
				//uiRemainPixInit();
				//appStillOsdInit();
			#else//new method
				menuExit();	
				osMsgPost(SP1K_MSG_CARD_PLUG_IN);
			#endif
			break;
			
		case SP1K_MSG_CARD_PLUG_OUT:
			appStorageMount(K_MEDIA_NANDF);
			uiRemainPixInit();
			menuExit();	
			//osMsgPost(SP1K_MSG_STATE_INIT);
			//uiRemainPixInit();
			//appStillOsdInit();
			//osMsgFlush();
			//uiOsdDialogDisp(ID_STR_NO_CARD_);
			break;
			
		case SP1K_MSG_CARD_NOT_SUPPORT:
			menuExit();	
			osMsgPost(SP1K_MSG_CARD_NOT_SUPPORT);
			break;
			
    	case SP1K_MSG_USB_PLUG_IN:
		menuExit();
		if (storageReadyflag==SUCCESS) {
			if (USB_DBG) {
					sp1kHalUSBSwPlugIn();
				} else {
				osMsgPost(SP1K_MSG_STATE_TO_USB);
			}				
		}
		break;
    	case SP1K_MSG_USB_PLUG_OUT:
		break;
	case SP1K_MSG_BAT_LV_UPDATE://jintao.liu 2008-3-13 add for battery action
		uiUpdateBatteryLevel();
		appBattStsHandle();
		break;
	case SP1K_MSG_BAT_EMPTY:
		sp1kOsdSelWinSet(-1, -1, -1, -1, 0, -1);
		uiUpdateOSDBatEmpty();
		osMsgPost(SP1K_MSG_POWER_OFF);
		sp1kBtnDisableAll();//ready to power off, disable all button!
		break;

	case SP1K_MSG_POWER_OFF:
		//break;
	case SP1K_MSG_KEY_PRESS_POWER:
		menuExit();
		appPowerOffProc();
		break;
	case SP1K_MSG_TV_PLUG_IN:
	case SP1K_MSG_TV_PLUG_OUT:
		
		if (MENU_MARK_ROTATE_ROTATE == menuPos ||\
			MENU_MARK_ROTATE_SAVE   == menuPos ||\
			MENU_MARK_ROTATE_BACK   == menuPos )//jintao.liu 2008-6-23 for mantis 26704
		{
			sp1kPbParamSet(PB_PARAM_ROT, 0);  
			sp1kPbSingleImgPlay(DOS_FileIndexGet(pbFile.dwIndex));
			//menuExit();
		}
		menuExit();
		appDispSet();
		break;
	default:

		/*********************************************
		* jintao.liu 2008-6-17 add to mask cp to card
		*
		* Note:
		* the below code avoid xdata overflow
		*/
		#if (!CP_TO_CARD_EN)
			{	
				UINT8 i = 0;
				if (i != 0)
					appCopy2Card(SP1K_FILE_PROC_ONE, K_Copy_Nand2Card);
			}
		#endif
		
		break;
	}

	preMsg = msg;
	menuProcDbgMsg(1);
}

//-----------------------------------------------------------------------------
//menuInit
//-----------------------------------------------------------------------------
void menuInit(void) USING_0
{
	UINT32 menuPos;

	switch ( appPreStateGet(0) )
	{
		case APP_STATE_STILL_VIEW:
			menuPos = MENU_MARK_STILL;
			break;
		case APP_STATE_VIDEO_VIEW:	
			menuPos = MENU_MARK_VIDEO;
			break;	
		case APP_STATE_AUDIO_REC:		
			menuPos = MENU_MARK_AUDIO;
			break;
			
		case APP_STATE_VIDEO_PLAY:			
		case APP_STATE_STILL_PLAY:
		case APP_STATE_MUTI_PLAY:
			menuPos = MENU_MARK_PLAYBACK;
			break;

		case APP_STATE_USB:
			menuPos = MENU_MARK_DPS;
			break;
		default:
			menuPos = MENU_MARK_STILL;
	}

	menuPosBackup = menuPos;
	menuProcCurrPosSet (menuPos);
}

//-----------------------------------------------------------------------------
//menuExit
//-----------------------------------------------------------------------------
void menuExit(void) USING_0
{
	UINT8 msg;
	
	switch ( appPreStateGet(0) )
	{
		case APP_STATE_STILL_VIEW:
			msg = SP1K_MSG_STATE_TO_STILL_VIEW;
			break;	
		case APP_STATE_VIDEO_VIEW:
			msg = SP1K_MSG_STATE_TO_VIDEO_VIEW;
			break;

		case APP_STATE_AUDIO_REC:
			sp1kAudioRecTypeSet(AUDIO_TYPE_NORMAL);
			msg = SP1K_MSG_STATE_TO_AUDIO_REC;
			break;
					
		case APP_STATE_STILL_PLAY:
			msg = SP1K_MSG_STATE_TO_STILL_PLAY;
			break;
		case APP_STATE_MUTI_PLAY:
			msg = SP1K_MSG_STATE_TO_MULTI_PLAY;
			break;

		case APP_STATE_VIDEO_PLAY:			
			msg = SP1K_MSG_STATE_TO_VIDEO_PLAY;
			break;

 		case APP_STATE_USB:
			msg = SP1K_MSG_STATE_TO_USB;
			break;

		default:
			msg = SP1K_MSG_STATE_TO_STILL_VIEW;
			break;
	}

	sp1kOsdClear(ID_ICON_NONE, 0);
	sp1kOsdSelWinSet(-1, -1, -1, -1, 0, -1);
	osMsgPost(msg);
}

